
<html>

  <HEAD>
  
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  
    <link rel="stylesheet" href="style/default.css" type="text/css">

    <title>JAXB RI 2.1.9 fcs -- Using SchemaGen with Ant
    </title>
    <link rel="alternate" href="https://jaxb.dev.java.net/servlets/ProjectNewsRSS" type="application/rss+xml">
  </HEAD>

  <BODY>
    <h1>
      <banner>
    Java
        <sup>
          <font size="-2">TM</font>
        </sup> Architecture for XML Binding
  
      </banner>
      <br>
      Using SchemaGen with Ant 
    
    </h1>
    <center>
      <b>Implementation Version:</b> 2.1.9 fcs
      <br>
    </center>
    <table class="navbar" cellspacing="0">
      <tr>
        <td class="inactive">
          <a href="index.html">JAXB 2.0</a>
        </td>
        <td class="active">
          <a>Tools</a>
        </td>
        <td class="inactive">
          <a href="jaxb-1_0.html">JAXB 1.0.x</a>
        </td>
        <td class="inactive">
          <a href="vendor.html">JAXB RI Extensions</a>
        </td>
        <td class="inactive">
          <a href="community.html">JAXB Community</a>
        </td>
      </tr>
    </table>
    <div class="subnavbar">
      <ul>
        <li class="first">
          <a href="xjc.html">
            <span>XJC </span>
          </a>
        </li>
        <li>
          <a href="xjcTask.html">
            <span>XJC Ant Task </span>
          </a>
        </li>
        <li>
          <a href="schemagen.html">
            <span>SchemaGen </span>
          </a>
        </li>
        <li>
          <a href="schemagenTask.html">
            <span class="active">SchemaGen Ant Task </span>
          </a>
        </li>
        <li>
          <a href="3rdparty.html">
            <span>3rd Party Tools </span>
          </a>
        </li>
      </ul>
    </div>
  
    <header></header>

  
    <p>
    The 
      <code>jaxb-xjc.jar</code> file contains the 
      <code>SchemaGenTask.class</code> file, which allows the schema generator to be invoked from the 
      <a href="http://jakarta.apache.org/ant">Ant</a> build tool. To use 
      <code>SchemaGenTask</code>, include the following statement in your 
      <code>build.xml</code> file:
    


    <pre class="ant-example">
&lt;taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask"&gt;
  &lt;classpath&gt;
    &lt;fileset dir="path/to/jaxb/lib" includes="*.jar" /&gt;
  &lt;/classpath&gt;
&lt;/taskdef&gt;
</pre>

  
    <p>
    This maps 
      <code>SchemaGenTask</code> to an Ant task named 
      <code>schemagen</code>. For detailed examples of using this task, refer to the 
      <tt>build.xml</tt> files used by the java to schema 
      <a href="samples.html">sample applications</a>.

	
    
    <h2>Synopsis</h2>
	
    <h3>Environment Variables</h3>
	
    <ul>
	  
      <li>
        <a href="http://wiki.apache.org/ant/TheElementsOfAntStyle">ANT_OPTS</a>
			- command-line arguments that should be passed to the JVM. For example,
			you can define system properties or set the maximum Java heap size here.
      </li>
	
    </ul>

	
    <h3>Parameter Attributes</h3>
		
    <p>
      <code>schemagen</code> supports most of the attributes defined by 
      <a href="http://ant.apache.org/manual/CoreTasks/javac.html">the javac task</a>, plus the following parameter attributes.
    

    <table border="1" summary="">
  
      <thead> 
        <tr>
    
          <td>
            <b>Attribute</b>
          </td>
    
          <td>
            <b>Description</b>
          </td>
    
          <td>
            <b>Required</b>
          </td>
  
        </tr>
  
      </thead> 
      <tbody>
    
        <tr>
      
          <td>destdir</td>
      
          <td>Base directory to place the generated schema files</td>
      
          <td>No</td>
    
        </tr>
    
        <tr>
      
          <td>classpath</td>
      
          <td>Works just like the nested &lt;classpath&gt;element</td>
      
          <td>No</td>
    
        </tr>
    
        <tr>
      
          <td>episode</td>
      
          <td>
        If specified, generate an episode file in the specified name.
        For more about the episode file, see 
            <a href="schemagen.html#-episode">the schemagen page</a>.
      
          </td>
      
          <td>No</td>
    
        </tr>

  
      </tbody>

    </table>
	
    <h3>Nested Elements</h3>

    <p>
      <code>xjc</code> supports all the nested elements defined by 
      <a href="http://ant.apache.org/manual/CoreTasks/javac.html">the javac task</a>,
the following nested element parameters.
    
	
    <div class="nested-elements">
  	
      <h3>schema</h3>
  	
      <p>Control the file name of the generated schema. This element takes a mandatory 
        <tt>namespace</tt> attribute and a mandaotry 
        <tt>file</tt> attribute. When this element is present, the schema document generated for the specified namespace will be placed in the specified file name. 
      
  	
      <p> The file name is interpreted as relative to the destdir
attribute. In the absence of the destdir attribute, file names are
relative to the project base directory. This element can be specified
multiple times. 
  
      <h3>classpath</h3>
  
      <p> A 
        <a href="http://ant.apache.org/manual/using.html#path">path-like
structure</a> that represents the classpath. If your Java
sources/classes depend on other libraries, they need to be available in
the classpath. 
      

    </div>



    <h2>Examples</h2>

    <p>Generate schema files from source files in the 
      <tt>src</tt> dir and
place them in the 
      <tt>build/schemas</tt> directory.


      <pre class="ant-example">
&lt;schemagen srcdir="src" destdir="build/schemas"&gt;
</pre>

	
    
    <p>Compile a portion of the source tree.

      <pre class="ant-example">
&lt;schemagen destdir="build/schemas"&gt;
  &lt;src  path="src" /&gt;
  &lt;exclude name="Main.java"/&gt;
&lt;/schemagen&gt;
</pre>

	
    
    <p>Set schema file names.

      <pre class="ant-example">
&lt;schemagen srcdir="src" destdir="build/schemas"&gt;
  &lt;schema namespace="http://myschema.acme.org/common" file="myschema-common.xsd" /&gt;
  &lt;schema namespace="http://myschema.acme.org/onion" file="myschema-onion.xsd" /&gt;
&lt;/schemagen&gt;
</pre>
	
	
    
    <hr>
	
    <div class="footer">
	  $Revision: 1.1 $
      <br>
	  $Date: 2007/12/05 00:49:15 $
	
    </div>



  </BODY>
</html>